package cn.clwxy.gdz.controller.presonalCenter;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.clwxy.gdz.controller.admin.BaseServlet;
import cn.clwxy.gdz.service.PersonalCenterInfoActService;
import cn.clwxy.gdz.service.PersonalCenterInfoActServiceImpl;
import cn.clwxy.gdz.util.MD5Encrypter;

@WebServlet(urlPatterns = { "/GDZjiajiaowang/PersonalCenter" })
public class PersonalCenterDeleteItServlet extends BaseServlet {
	PersonalCenterInfoActService pc = new PersonalCenterInfoActServiceImpl();

	@Override
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		Integer teacherId = Integer.parseInt(request.getParameter("teacherId"));
		String teacherPwd = request.getParameter("teacherPwd");
		String teacherPhone = request.getParameter("teacherPhone");

		// 加密
		teacherPwd = MD5Encrypter.encrypt(teacherPhone + teacherPwd
				+ teacherPhone);
		int count = pc.updateisDelete(teacherId, teacherPwd);
//		System.out.println("注销结果：" + resu);
//		if(resu==1){
//			response.getWriter().write("y");
//			
//		}else{
//			response.getWriter().write("n");
//			
//		}
		Map results=new HashMap();
		results.put("a",count);
		response.setContentType("application/json");
		if(count==1){
			System.out.println("正确");
			response.getWriter().write("1");
		}else{
			System.out.println("错误");
			response.getWriter().write("0");
		}

		response.getWriter().flush();
		response.getWriter().close();
		
	}
	// public int delete(HttpServletRequest request, HttpServletResponse
	// response) {
	// System.out.println("进入delete方法");
	// Integer teacherId = Integer.parseInt(request.getParameter("teacherId"));
	// String teacherPwd = request.getParameter("teacherPwd");
	//
	// return pc.updateisDelete(teacherId, teacherPwd);
	// }
}